const connection = require("../app/database")
class issue{
    async getissue(l,m){
        const statement  =`SELECT  JSON_OBJECT('uid',a.id,'type',a.type,'content',a.content, 'like',l.alike, 'title',a.title,'userid',u.id,'createtm',a.createAt,'updatatm',a.updateAt,'name',u.name,'reward',a.reward) essay 
        from article a 
        LEFT JOIN user u on a.user_id = u.id
        LEFT JOIN alike  l on a.id = l.article_id
        WHERE a.type = 1
        LIMIT ?,? ;`
        const data  =await connection.execute(statement,[l,m])
        return data[0]
    }
}
module.exports = new issue()